#pragma strict
//////////////////////////////////////////////////////
///水平滚动.
//////////////////////////////////////////////////////
/** 开始x,世界坐标 */
var startX:float;
/** 结束,世界坐标 */
var endX:float = -1;
/** 滚动速度 */
var speed:float = 0.5;
/** 当前的x */
var curX:float = 0;
/** 滚动完毕发送通知名. */
var OnCompleteEventName:String = "OnScrollComplete";

var isScroll:boolean;

function Start () {
	curX = startX = transform.position.x;
}

function Update () {
	if(isScroll){
		curX -= speed * Time.deltaTime;
		if(curX <= endX){
			curX = startX;
			SendMessage(OnCompleteEventName,new UIEventArgs(transform),SendMessageOptions.DontRequireReceiver);
		}
		transform.position.x = curX;
	}
}
/** delay秒后重新开始. */
function Restart(delay:float){
	Stop();
	// yield WaitForSeconds(delay);
	isScroll = true;
}
/** 停止 */
function Stop(){
	isScroll = false;
	transform.position.x = startX;
}